<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>X+ 约课系统 - 编辑老师</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="../../static/favicon.ico" th:href="@{/static/favicon.ico}">
    <link href="../../static/css/bootstrap.min.css?v=3.3.6" th:href="@{/static/css/bootstrap.min.css(v='3.3.6')}" rel="stylesheet">
    <link href="../../static/css/font-awesome.css?v=4.4.0" th:href="@{/static/css/font-awesome.css(v='4.4.0')}" rel="stylesheet">
    <link href="../../static/css/animate.css" th:href="@{/static/css/animate.css}" rel="stylesheet">
    <link href="../../static/css/style.css?v=4.1.0" th:href="@{/static/css/style.css(v='4.1.0')}" rel="stylesheet">
    <!-- bootstrap-datepicker -->
    <link href="../../static/css/plugins/datapicker/datepicker3.css" th:href="@{/static/css/plugins/datapicker/datepicker3.css}" rel="stylesheet">

    <link href="../../static/css/plugins/sweetalert/sweetalert.css"
          rel="stylesheet" th:href="@{/static/css/plugins/sweetalert/sweetalert.css}">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>编辑老师</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <form method="post" id="editForm" class="form-horizontal" th:action="@{/user/teacherEdit.do}">
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><i class="red">*</i>老师姓名</label>
                                <div class="col-sm-10">
                                	<!-- 隐藏字段 - 存放id -->
                                	<input type="hidden" name="id" value="1" th:value="${teacherMsg.id}" class="form-control">
                                    <input type="text" th:value="${teacherMsg.name}" class="form-control" value="张老师" name="name">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><i class="red">*</i>手机号</label>
                                <div class="col-sm-10">
                                    <input type="text" th:value="${teacherMsg.phone}" class="form-control" value="13877996655" name="phone">
                               		<span th:if="${CHECK_PHONE_EXIST}" class="text-danger">手机号跟其它用户撞名了</span>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label"><i class="red">*</i>邮  箱</label>
                                <div class="col-sm-10">
                                    <input type="email" th:value="${teacherMsg.roleEmail}" class="form-control" value="misszhang@126.com" name="roleEmail">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label"><i class="red">*</i>性别</label>
                                <div class="col-sm-10">
                                    <label class="checkbox-inline">
                                        <input type="radio" name="sex" value="男" th:attr="checked=${teacherMsg.sex == '男'? true :false}"> 男
                                    </label>
                                    <label class="checkbox-inline">
                                        <input type="radio" name="sex" value="女" checked th:attr="checked=${teacherMsg.sex == '女'? true :false}"> 女
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">
                                    出生日期</label>
                                <div class="col-sm-3">
                                    <input id="myDate" th:value="${birthdayStr}" name="birthday" class="form-control" value="1998-12-12"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">老师介绍</label>
                                <div class="col-sm-10">
                                    <textarea class="form-control"  name="introduce">[[${teacherMsg.introduce}]]</textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">备注</label>
                                <div class="col-sm-10">
                                    <textarea class="form-control" name="note">[[${teacherMsg.note}]]</textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-2 col-sm-offset-2">
                                    <button type="submit" class="btn btn-success">保存</button>
                                    <button id="reset" type="reset" class="btn btn-white">取消</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="../../static/js/jquery.min.js?v=2.1.4" th:src="@{/static/js/jquery.min.js(v='2.1.4')}"></script>
<script src="../../static/js/bootstrap.min.js?v=3.3.6" th:src="@{/static/js/bootstrap.min.js(v='3.3.6')}"></script>

<!-- 自定义js -->
<script src="../../static/js/content.js?v=1.0.0" th:src="@{/static/js/content.js(v='1.0.0')}"></script>

<!-- Peity -->
<script src="../../static/js/plugins/peity/jquery.peity.min.js" th:src="@{/static/js/plugins/peity/jquery.peity.min.js}"></script>

<!-- Data picker -->
<script src="../../static/js/plugins/datapicker/bootstrap-datepicker.js" th:src="@{/static/js/plugins/datapicker/bootstrap-datepicker.js}"></script>
<script src="../../static/js/plugins/datapicker/bootstrap-datepicker.zh-CN.min.js" th:src="@{/static/js/plugins/datapicker/bootstrap-datepicker.zh-CN.min.js}"></script>

<script src="../../static/js/plugins/sweetalert/sweetalert.min.js"
        th:src="@{/static/js/plugins/sweetalert/sweetalert.min.js}"></script>
</body>
<script>

    $(function () {
        $('#editForm').on('submit', function (e) {
            e.preventDefault();
            const serializeFormUpdate = $(this).serialize();

            swal({
                title: "您确定要更新老师信息么",
                text: "注意:您正在更新老师的信息",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确认",
                closeOnConfirm: false
            }, function () {
                $.ajax({
                    url: '[[${#request.getContextPath()}]]/user/teacherEdit.do',
                    type: 'post',
                    data: serializeFormUpdate,
                    dataType: 'json',
                    success: function (data) {
                        if (data.code === 0) {
                            setTimeout(function () {},100);
                            swal(data.msg, "", "success");
                            setTimeout(function () {
                                window.location.href='[[${#request.getContextPath()}]]/user/x_teacher_list.do'
                            }, 2000);
                        } else {
                            setTimeout(function () {},100);
                            swal(data.msg, "", "info");
                        }
                    },
                    error: function (jqXHR) {
                        // 失败
                        alert("更新失败！,请联系管理员！！");
                    }
                });
            });


        })

        $('#reset').click(function () {
            window.location.href='[[${#request.getContextPath()}]]/user/x_teacher_list.do'
        });



    });




    $(function () {
        /*时间控件配置*/
        $('#myDate').datepicker({
            language: "zh-CN",
            clearBtn: true,//清除
            autoclose: true,
            todayHighlight: true,
            format: 'yyyy-mm-dd',
            todayBtn: false,//今日按钮
            startDate: '1970-1-1', //与你自己设置的格式一致yyyy-mm-dd，未设置的话与默认格式一致mm/dd/yyyy
            endDate: '2070-1-1'
        });

    });


</script>

</html>
